package com.inspectortime.webapp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.inspectortime.domain.Inspector;
import com.inspectortime.repository.Repository;

public class InspectorViewController implements Controller {

	private Repository repository;
	
	public void setRepository(Repository repository) {
		this.repository = repository;
	}
	
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String id = request.getParameter("id");
		Inspector inspector = repository.loadInspector(id);
		
		ModelAndView mv = new ModelAndView("inspector");
		mv.addObject("inspector", inspector);
		return mv;
	}

}
